//
//  LGPatientWeightHeader.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/3/6.
//

#import "LGPatientWeightHeader.h"

#define weightCenterX      viewPix(95)+iPadMargin(20)
#define waistlineCenterX   viewPix(186)+iPadMargin(20)
#define BMICenterX         (Screen_W - viewPix(32) - viewPix(70) - iPadMargin(80))

@interface LGPatientWeightHeader()
/**   */
@property (nonatomic , strong)UIView *baseView;
/**   */
@property (nonatomic , strong)UIView *bottomView;
/**   */
@property (nonatomic , strong)UILabel *weightLabel;
/**   */
@property (nonatomic , strong)UILabel *unitLabel;
/**   */
@property (nonatomic , strong)UILabel *waistlineLabel;
/**   */
@property (nonatomic , strong)UILabel *waistlineUnit;
/**   */
@property (nonatomic , strong)UILabel *BMILabel;

@end

@implementation LGPatientWeightHeader

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.clipsToBounds = YES;
        self.backgroundColor = [UIColor clearColor];
        [self addSubview:self.baseView];
        [self.baseView addSubview:self.monthLabel];
        [self.baseView addSubview:self.bottomView];
        [self.baseView addSubview:self.weightLabel];
        [self.baseView addSubview:self.unitLabel];
        [self.baseView addSubview:self.waistlineLabel];
        [self.baseView addSubview:self.waistlineUnit];
        [self.baseView addSubview:self.BMILabel];
        [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).offset(viewPix(5));
            make.left.bottom.equalTo(self).offset(viewPix(16));
            make.right.equalTo(self).offset(-viewPix(16));
        }];

        [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.baseView).offset(viewPix(38));
            make.left.bottom.right.equalTo(self.baseView);
        }];
        [self.weightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.baseView.mas_left).offset(weightCenterX);
            make.top.equalTo(self.baseView).offset(viewPix(46));
        }];
        [self.unitLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.weightLabel.mas_right).offset(3);
            make.bottom.equalTo(self.weightLabel);
        }];
        [self.waistlineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.baseView.mas_left).offset(waistlineCenterX);
            make.centerY.equalTo(self.weightLabel);
        }];
        [self.waistlineUnit mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.waistlineLabel.mas_right).offset(3);;
            make.bottom.equalTo(self.waistlineLabel);
        }];
        [self.BMILabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.baseView.mas_left).offset(BMICenterX);
            make.centerY.equalTo(self.weightLabel);
        }];
    }
    return self;
}

-(UIView *)baseView{
    if(!_baseView){
        _baseView = [UIView shadowViewWithColor:@"#B2BDC7" offset:CGSizeMake(0, 2) opacity:0.15 radius:8];
        _baseView.backgroundColor = [UIColor whiteColor];
    }
    return _baseView;
}

-(UILabel *)monthLabel{
    if(!_monthLabel){
        _monthLabel = [UILabel lableWithText:@"" colorString:@"#666666" textFont:LGFont(16) textAlignment:NSTextAlignmentLeft lines:1];
        _monthLabel.frame = CGRectMake(viewPix(12), viewPix(10), viewPix(150), viewPix(22));
    }
    return _monthLabel;
}


-(UIView *)bottomView{
    if(!_bottomView){
        _bottomView = [[UIView alloc] init];
        _bottomView.backgroundColor = [UIColor colorWithString:@"#F5FBFF"];
    }
    return _bottomView;
}

-(UILabel *)weightLabel{
    if(!_weightLabel){
        _weightLabel = [UILabel lableWithText:@"体重" colorString:@"#666666" textFont:LGFont(16) textAlignment:NSTextAlignmentCenter lines:1];
    }
    return _weightLabel;
}

-(UILabel *)unitLabel{
    if(!_unitLabel){
        _unitLabel = [UILabel lableWithText:@"kg" colorString:@"#999999" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _unitLabel;
}

-(UILabel *)waistlineLabel{
    if(!_waistlineLabel){
        _waistlineLabel = [UILabel lableWithText:@"腰围" colorString:@"#666666" textFont:LGFont(16) textAlignment:NSTextAlignmentCenter lines:1];
    }
    return _waistlineLabel;
}

-(UILabel *)waistlineUnit{
    if(!_waistlineUnit){
        _waistlineUnit = [UILabel lableWithText:@"cm" colorString:@"#999999" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _waistlineUnit;
}

-(UILabel *)BMILabel{
    if(!_BMILabel){
        _BMILabel = [UILabel lableWithText:@"BMI" colorString:@"#666666" textFont:LGFont(16) textAlignment:NSTextAlignmentCenter lines:1];
    }
    return _BMILabel;
}

@end
